package com.google.code.p.restrpc.client.cluster;

import java.util.List;

import com.google.code.p.restrpc.RpcRequest;
import com.google.code.p.restrpc.RpcResponse;
import com.google.code.p.restrpc.client.loadbalance.LoadBalanceFailedException;

/**
 * @author dz
 */
public class FailBackStrategy extends AbstractFailureRecoveryStrategy {
    
    public FailBackStrategy() {
        super();
    }
    
    @Override
    public RpcResponse invoke(ClusteredRpcContext context,
                              List<RpcRequest> requests) {
//        int selectedPath = context.getLoadBalanceStrategy()
//                                  .select(context.getRpcContext()
//                                                 .getServiceName(),
//                                          context.getRpcContext()
//                                                 .getMethodName(),
//                                          requests.toArray(new RpcRequest[] {}));
//        if (selectedPath < 0) {
//            throw new LoadBalanceFailedException("Can't determine the destination of rpcRequest!");
//        }
//        
//        return context.getRestInvoker().send(requests.get(selectedPath));
        //TODO implement fail safe strategy
        throw new UnsupportedOperationException();
    }
}
